/*
 * @Author: 李石
 * @Date: 2024-04-09 16:20:30
 * @LastEditors: lishi
 * @LastEditTime: 2024-05-21 10:25:43
 * @Description: 
 * Copyright (c) 2024 by ${lishi0105@163.com}, All Rights Reserved. 
 */
#ifndef _FRAME_DATA_HPP_
#define _FRAME_DATA_HPP_
#include <iostream>
#include <memory>
#include "mk_frame.h"

class FrameData {
public:
    using Ptr = std::shared_ptr<FrameData>;
    static Ptr CreateShared(const mk_frame frame_tmp) {
        return Ptr(new FrameData(frame_tmp));
    }
    static Ptr CreateShared(const void* data_tmp, size_t size_tmp, const mk_frame frame_tmp) {
        return Ptr(new FrameData(data_tmp, size_tmp, frame_tmp));
    }
    static Ptr CreateShared(const void* data_tmp, size_t size_tmp, int32_t codec_id_tmp) {
        return Ptr(new FrameData(data_tmp, size_tmp, codec_id_tmp));
    }
    static Ptr CreateShared(const void* data_tmp, size_t size_tmp, int32_t codec_id_tmp, uint64_t pts_tmp) {
        return Ptr(new FrameData(data_tmp, size_tmp, codec_id_tmp, pts_tmp));
    }
    ~FrameData();

    void dts(uint64_t dts_tmp) { m_dts = dts_tmp; }
    uint64_t dts() const { return m_dts; }
    uint64_t pts() const { return m_pts; }
    size_t prefixSize() const { return m_prefixSize; }
    bool keyFrame() const { return keyFrame_; }
    bool dropAble() const { return dropAble_; }
    bool configFrame() const { return configFrame_; }
    bool decodeAble() const { return decodeAble_; }
    const uint8_t* data() const { return m_data; }
    size_t size() const { return m_size; }
    int32_t codec_id() const { return m_codec_id; }
    std::string codec_name() const {return codec_name_;}
    bool isVaild() const { return m_is_vaild; }
    std::string toString() const;
    friend std::ostream& operator<<(std::ostream& os, const FrameData::Ptr& Frame);

private:
    FrameData(const mk_frame frame);
    FrameData(const void *, size_t , int32_t);
    FrameData(const void *, size_t , int32_t, uint64_t);
    FrameData(const void *, size_t , const mk_frame);
    FrameData(const FrameData& ) = delete;
    FrameData& operator=(const FrameData&) = delete;
private:
    uint8_t*    m_data;
    size_t      m_size;
    uint64_t    m_dts;
    uint64_t    m_pts;
    size_t      m_prefixSize;
    bool        keyFrame_;
    bool        dropAble_;
    bool        decodeAble_;
    bool        configFrame_;
    int32_t     m_codec_id;
    std::string codec_name_;
    bool        m_is_vaild;
};
#endif // _FRAME_DATA_HPP_